#region Using
using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
#endregion Using

namespace CY.GFive.Core.Services.DALService
{
	internal sealed class VoteItemService
	{
		#region Constructor

		static VoteItemService()
		{
			LoadProvider();
		}

		#endregion Constructor

		#region Provider model

		private static volatile Providers.DALProvider.IVoteItemProvider provider;
		private static object syncLock = new object();

		private static void LoadProvider()
		{
			if (provider == null)
			{
				lock (syncLock)
				{
					if (provider == null)
					{
						string path = CY.GFive.Configuration.ConfigurationManager.Providers.DALProviders.Default.Path;
						string className = CY.GFive.Configuration.ConfigurationManager.Providers.DALProviders.Default.Namespace + ".VoteItemProvider";
						provider = System.Reflection.Assembly.Load(path).CreateInstance(className) as Providers.DALProvider.IVoteItemProvider;
					}
				}
			}
		}

		#endregion Provider model

		public static Business.VoteItem Select(int id)
		{
			return provider.Select(id);
		}

		public static void Update(Business.VoteItem voteItem)
		{
			provider.Update(voteItem);
		}

		public static void Delete(Business.VoteItem voteItem)
		{
			provider.Delete(voteItem);
		}

		public static void Insert(Business.VoteItem voteItem)
		{
			provider.Insert(voteItem);
		}
	}
}
